error handling added to deal with corrupted jpeg