put image opening in a try-except