fix unicode compatibility error when variable `pretty' contains Chinese characters

@NimitS1  let me try to explain this fix again. The original code at line 225 and 226 above is

    bwritten = os.write(f.fileno(), bytes(pretty, 'utf8'))
    if bwritten != len(pretty):
        ...
where, if branch attempts to adjust that whether all content referenced by variable pretty is written in file correctly. As the code is showing, whether the write action succeeds depends on the equivalent between `bwritten` and `len(pretty)`.

`bwritten` equals to the number of bytes wrote to file, whereas `len(pretty)` equals to the number of characters within string variable `pretty`. Meanwhile, in Python 3, pretty is an Unicode string. This is why it must be encoded in utf8 before writing to file. Obviously, if pretty contains Chinese characters, or any other wide characters, `len(pretty)` does not equal to `len(bytes(pretty, 'utf8'))`, then `bwritten != len(pretty)` will always equal to True in turn. This is the error this patch fixes.