Fix #645: thumbnail generation for JPEG images fail with latest PHP version