The curdling is caused by high heat, which is hard to avoid in an oven. So to keep the sauce together, tackle it before the dish goes in the oven by making a smooth cheese sauce. You can also layer the potatoes and cheese with flour so that the cheese sauce self makes during the bake.