Add hts_set_threads() file I/O threading API

Currently just calls through to bgzf_mt() for BGZF files.  Eventually
CRAM threading should be plugged in here too, but the API may well need
changes first.  Documented as more than usually subject to change.
Fix bgzf_write() and bgzf_flush_try() error handling

As there is buffering involved, writes actually either complete or
abort with I/O errors, so clarify bgzf_write()'s documented return
value accordingly.  bgzf_write() now returns -1 when bgzf_flush()/etc
fails, rather than merely exiting the loop and returning a misleading
successful value.

Also fix error handling within the mt_* functions and ensure that their
return values are checked.  Separate mt_queue (adds an item to the queue)
from mt_flush_queue (now just flushes all items on the queue).
Fix bam_write1() error handling

Propagate errors returned from bgzf_flush_try() and bgzf_write().

(Also, in sam_write1(), add writing the newline to the existing
error-checked hwrite() call rather than using a separate call.)
Merge branch 'bcftools+calling' into develop