Preheat oven to 400F
Grease an 8x8 casserole dish with butter or oil spray
Arrange potato and onion slices in rows, interlaying them. Season with salt and pepper.
Melt butter in a medium-sized saucepan. Add flour and cook for a couple of minutes until bubbly.
Stir in milk and mix with a whisk until the mixture thickens. Add shredded cheese and mix until melted. Remove from heat.
Pour cheese mixture over potatoes and onions covering all of them.
Cover with foil and bake for 1 ½ hour. Five minutes before removing the casserole from the oven, remove foil and broil. Garnish with chopped chives or parsley.