Fix image copy function.