Ported to pillow implementation of PIL