Putting image creation in autoreleasepool to avoid mem leak