Check index file magic numbers and I/O

Reading a BAI, CSI, or tabix index file should fail if the magic number
is incorrect, the file is truncated (or reading otherwise fails), or
memory allocation fails.  There is probably further consistency checking
that could be done too.  Fixes samtools/samtools#47.