If someone chooses to load a TIFF or a PSD or an AIFF or…

then you either use an existing C library (the most likely approach) or if you are determined to re-implement it you have to be careful parsing their bytes.