handle error: cannot write mode P as JPEG