##
1) your script must print appropriate Content-header -
print "Content-type: image/jpeg\n\n";
or
use CGI;
my $cgi = new CGI;
print $cgi->header( 'image/jpeg' );
2) your script should generate an image with GD (or ImageMagick),
or load a blank image from disk, and then annotate the image with
hitcount calculated by your script.
3) print this image to the STDOUT, probably need to turn on binmode if
you are on a windows platform.