Fixed exception handling when extracting images