In a saucepan over medium heat, whisk together milk, sugar, and cornstarch until smooth. In a separate bowl, beat the egg yolks, then slowly whisk in about ½ cup of the hot milk mixture to temper the eggs. Pour the egg mixture back into the saucepan, whisking constantly, and cook until thickened (about 3-5 minutes). Remove from heat and stir in butter and vanilla extract. Let the custard cool for 10 minutes, then cover with plastic wrap.