updated to work Pillow rather than PIL