added check to see if html output images rendered
Cleaned source code in tohtml.py