changing exception catch to comply with python 3