Fix sethostname() failure when passed bytes

My implementation of sethostname() was broken and failed when passed
bytes on Python 3.  Update the implementation to match CPython -- that
is, use bytes if provided, or fsencode() when str is provided.
1 job for topic/default/sethostname-bytes in 7 minutes and 17 seconds