Replace all IOError by OSErrors.

Starting with Python 3.3, IOError is just an alias for OSError.
Handle OSError exceptions where appropriate.

Fixes #25.