IOError can be thrown in 3 consecutive lines of code: read(), open() and load() - the last one is because PIL.Image.open is a lazy operation; load() makes the whole thing and the file may be truncated, etc.