Fix some bugs in image processing
First template