better write_message() / build_message() interface

it's now agnostinc about the number of records contained in the message