Changed exceptions to be py3k compatible