Fix remaining encoding issues with python 3
- Cast all unicode strings to bytes arrays before passing them through to fcntl.ioctl, as the string width of unicode strings is different and not downcast to bytes when passed to fcntl.ioctl.
- Use array.array(..).tobytes() instead of array.array(..).tostring() in python 3.2+, per the deprecation warning printed out by python 3.6 when the code is evaluated.