fix write len after converting