Set samtools sort's exit status from errors

If bam_merge_core2() fails, this needs to be reflected in the exit status.
Fix samtools sort -f temporary file names

Pull request #27 introduced a bug in which worker threads wrote
temporary files with different names (prefix.NNNN.bam) to those the
merge step tried to read (prefix.NNNN).

Now bam_sort_core_ext() has separate prefix and output filename
parameters, enabling future code allowing the temporary files to be
somewhere entirely separate from the output file (e.g., $TMPDIR).

(With -f, temporary files now have slightly odd names such as
foo.bam.0001.bam, but they're only temporary anyway...
Thanks to Chris Carr for reporting this bug.)