[ticket/11552] Fix overflow for large images

PHPBB3-11552