Your result isn't a matrix of MxNx3. Your result is a sequence of numbers. You can store them however you like.
Take the LCD screen you're reading this on, for instance. That is a 2D device, isn't it? Yet it looks like it would have a display of MxNx3. Look closer though. Very close. Get a magnifying glass and look reeeeeeal close.
It's actually a matrix of (Mx3)xN. Three physical pixels for every one you see - a red one, a green one, and a blue one.
So you actually have 3 times as many values in the X direction as you have pixels in the X direction.
That's a direct R/G/b interleaving, where every three entries in the matrix combine to make a single pixel value.
Or you could have three separate matrices of MxN - one to store the red pixel information, one the green and one the blue, if that makes more sense for what you're doing with the data.
Most systems though just choose to represent each pixel as a 24 or 32 bit value in a linear addressing scheme. Normally the 32 bits represent ARGB where A is an alpha value (transparency), and R, G and B represent the brightness of the three colours, all with 8 bit precision. 24 bit is the same but without the alpha information. (Unless you're Microsoft of course, when they like to do ABGR or other strange combinations in their file formats, but they're just daft).
Then that is just treated as a single list of numbers.
Say the image is 100x100 pixels in size, that would give you a list of 10,000 numbers to store in memory. The fact that it's a picture of 100x100 pixels is neither here nor there to the memory. It's only what you do with that data where the fact that it's a picture of 100x100 pixels matters.