Make thumbnailer handle errors more gracefully, import PIL.Image in a
pillow-compatible way.  Should help with issue #374.