Fixed compatibility issues with Pillow