Exception handling in preprocessing and image classes