Thank you davorg and Fletch
I think what you pointed out about the webserver setting seems to be right. I have now moved the script to cgi-bin folder
(file:///usr/local/apache/cgi-bin/simpleImage.cgi) and repeated chmod 755.
It still does the same (showing the code). Does this mean that just putting the code in cgi-bin does not solve the purpose. The major issue is that we donot have a sys admin which means I should learn the hard way :(
Thanks
Nagesh