EZP-22516: fixed: check that file is valid image