updated to use Pillow instead of PIL