Catch UnicodeDecodeError, fixes #640

When _encode_idna is called with a non-ASCII hostname, it raises
UnicodeDecodeError. Fix callers to catch the exception.