Implemented copyImage function