System and method for optical detection of a failure of the media feeding in an image forming apparatus