Fix IDNA encoding python3 issues

`encode('idna')` returns `bytes`, so we want to make sure we decode it
back to a `str` in python 3.