Move bitdepth/colortype check into its own function, and split
into more errors.