Fixed saving of models to binary format