I suspect that the problem lies here:
Code:
//Loop (most details of loop not shown)
...
The 'copy' part of the code shouldn't be taking anything close to 90 seconds for an 8 megapixel image. So what happens in the rest of the loop?