Fix for crash when using large images