Pil/Pillow encode errors can raise an OSError Exception

Related to #216 and #217