fixed PIL handling in patch_viewer.py