fixed exception handling to match the specs for ullib from http://docs.python.org/2/library/urllib.html