get_image_formats: make sure num_img_formats is 0 in case of error