Made generic generateHTMLPreview function

+ Added new function to ImageUtil