Fix handling of unicode strings in hdfs write function

Unicode strings need to be encoded using the system encoding before
being written. The code was instead trying to access them directy as a
python buffer, which would fail with a TypeError.