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

See #626