In a medium sauce pan melt butter over medium heat. Stir in flour until well incorporated and allow to cook for about a minute. Whisk in milk and cheese. Allow the mixture to cook over medium heat stirring occassionall until it starts to thicken. About 5 minutes.
Spray a casserole dish with non stick spray and layer half the potatoes out overlapping slightly.
Sprinkle with half the onions and salt and pepper to taste
Pour half the cheese mixture evenly over the potatoes
Repeat with remaining potatoes, onions, and sauce.
Baked covered at 350° for 2½ hours until potatoes are soft