Added class for ImageTemplate and fixed some bugs