Catch PIL imread problems early and generate error message

This addresses problems seen in #1154 and #1091.
I verified that `im.tell` is 0 before and after `im.getdata`, and the image loads just fine.