Why is my pastry cream (custard) grainy?
I think it all got too hot, but there might be other problems.


Did you mix the cornstarch in completely? Leaving undissolved cornstarch is a sure way to obtain 'blobs'.
Did you pour the hot milk onto the egg-mixture? You should do that very slowly and whisk vigorously (while trying to splash everything). If the eggs get too hot, they will coagulate.
Did you use a double boiler? Putting the pan on an open flame will make the bottom too hot and the eggs will coagulate.
Even if you did use a double boiler, did you whisk regularly while heating? The eggs at the bottom will become far warmer than the eggs in the center...


As rumtscho mentioned, a thermometer will be useful for monitoring the done-ness of the custard. 


  Generally, a fully cooked custard should not exceed 80 °C; it begins setting at 70 °C.


Source: Wikipedia