Refine the code, and add function to transfer image formate.