updated API calls to new format to write binary content of datastreams