Function to copy an image.