validation and error handling in GD.php - better handling of invalid image files