Fixed ComposeChannels and bugs with num_channels()

num_channels() is now a bit hacky, but necessary.  Also, the case where it is called without having an image generated first is very narrow and usually happens at most once, at initialization (when it's necessary to know, beforehand, the number of channels of the inputs, in order to construct the higher structures)

Don't those two sentences contradict each other?  The first one says they have to match, but the second says that what happens when they don't match is ok.