In a 9-11" cast iron (or oven-proof) skillet, sauté the onion with 1 Tbsp butter until soft. Then add 3 Tbsp more butter, and once melted whisk in the flour until its lightly browned and dissolved in the butter, about 30 seconds.
Season with salt and pepper to taste, then whisk in milk. Pour into a large bowl and set aside.
Arrange a layer of potato slices in bottom of skillet, sprinkle with salt and pepper and 1/3 of the cheese. Continue laying potatoes and cheese, finishing with a cheese layer. Dot the remaining 1 Tbsp of butter on top, then pour over the milk mixture.
Cover with foil and bake at 400°F for 1 hour. Remove foil then broil for another 5-10 minutes until top is golden.