minor changes to write_midi_message