Preheat oven to 375°F (190°C). Grease an 8-inch (20 cm) square baking dish with butter.
In a small saucepan, melt the butter over medium heat. Add the flour and stir until the mixture is smooth and bubbly. Gradually add the milk, stirring constantly. Cook until the mixture is thick and bubbly. Remove from heat and stir in the salt and pepper.
In a large bowl, combine the corn, cheese, and eggs. Add the sauce and mix until everything is well combined.
Pour the mixture into the prepared baking dish. Bake in preheated oven for 25 minutes or until the top is golden brown and the center is set.