small change to write function for new java api to set the write mode