simplify DataOutputStream.write
some changes for py3 compat