Adds checks for the bit depth and file length before getting pixel data.