Well, I'd expect that to work unless you're buffering output somewhere, and you're putting out something else before you get to the above code. Is that all there is in the file?
Try this, see if it dies at the message:
<?php
$file=$line='';
if(headers_sent($file,$line))
{
die("Shouldn't have got here, but headers have already been sent (in file $file, at line $line).");
}
header ("Content-type: image/png");
$img_handle = ImageCreate (230, 20) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
ImageString ($img_handle, 31, 5, 5, "My first Program with GD", $txt_color);
ImagePng ($img_handle);
?>