write the model to binary file