Compute the total size by multiplying the three dimensions together, allocate the result array, and use three nested loops – one for each dimension. Make a counter for the current position in the output array; increment that counter as you put items into the output array - something like this:
byte[,,] threeD = new byte[X,Y,Z];
byte[] res = new byte[X*Y*Z];
int pos = 0;
for (int x = 0 ; x != X ; x++)
for (int y = 0 ; y != Y ; y++)
for (int z = 0 ; z != Z ; z++)
res[pos++] = threeD[x,y,z];