Fixed writing wrapper

In python3 buffers and strings are handeled differently so I had to fix
what it was writing to be in binary.