Solving Memory Leak Issue for images