Make the IO more efficient by delaying IsDICOMFile check.

It makes sense to check whether a file is DICOM immediately before
reading it.  That way, whatever part of the file is was cached by
the first read will still be in cache during the second read.