Fix bgzf_write() for large (> 2GB) blocks

bgzf_write() takes a size_t length, so its internal counters need to be
size_ts or ssize_ts rather than ints if it is to operate on lengths up to
max(ssize_t) as advertised rather than just up to INT_MAX.  Also inline
the salient parts of mt_write() rather than duplicating the loop code.

Fixes samtools/samtools#67 (more than 2GB of headers fails), but note
that the BAM l_text field is a *signed* int32_t, so in fact BAM files
with such large headers are outwith the spec and likely not portable
to other BAM implementations, notably Picard.