Python 3 fixes for chmod and exceptions

I wasn't able to cleanly install in a python 3.2 environment, so I made these backwards compatible changes.