Fix #645: thumbnail generation for JPEG images fail with latest PHP versions (5.4-5.6)