fix writing of str on os.open'ed file (needed bytes)