Heat the oven to 350 F and lightly butter a 2-quart baking dish.
Cook the macaroni in boiling salted water according to the package directions. Drain the macaroni, return it to the pot, and toss it with the butter.
Reserve 1/2 cup of cheese and set it aside.
Cover the bottom of the baking dish with a layer of about one-third of the macaroni followed by a layer of half of the cheese. Repeat the layers, then top with the remaining one-third of the macaroni.
In a bowl, combine the milk, egg, dry mustard, salt, and ground black and cayenne peppers. Pour over the casserole.
Sprinkle with the reserved 1/2 cup of cheese and bake the casserole for 30 minutes, until hot and bubbly.