Preheat the oven to 325 degrees. Rub the butter over the surface of a baking dish (8x8x2). Peel and slice the potatoes one-fourth-inch thick. Pat dry with a kitchen towel and keep them covered while you prepare the liquid.
Pour the milk and cream into a saucepan. Add the garlic, thyme and shallot (if using). Heat slowly over low to medium heat. When small bubbles appear around the edge of the pan, remove from heat. Strain the liquid into a bowl of large measuring cup, sprinkle in the nutmeg and keep warm.
Layer the potato slices in the dish, slightly overlapping. Sprinkle with a little salt and pepper (you can use white pepper, but it has a slightly different flavor) between the layers. Pour half the warm milk/cream mixture, halfway through the layering process. Arrange the top layer carefully and pour the remaining liquid over. Sprinkle the cheese over the top and bake for about one hour, until golden and potatoes are cooked tender. Let the dish stand for about 5 minutes, then served sprinkled with fresh thyme leaves.