in reply to deleting a file after loading
If you are using GD to make an image, then all you need to do is print the binary data directly to STDOUT when you make it:
# lifted from GD.pm synopsis...
$im = new GD::Image(100,100);
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
# Important bit:
print "Content-type: image/png\n\n";
In the page which must access the image, put a normal img tag, but which src="path to script".