Spread about 1/3 of the potato slices into the bottom of the prepared baking dish. Top with about 1/3 of the onion slices. Sprinkle 3 tablespoons flour over the potato and onion. Arrange 2 tablespoons butter atop the flour. Season the entire layer with salt and pepper. Repeat layering twice more.