Add a check_and_save_image() function which encapsulates typical image upload handler functionality