When you use expressions like unsigned char idata[sz1][sz2], the space of the array is allocated in stack, while the space of the stack is somehow really small, which causes you problem.
But if you use unsigned char* idata = new char*[sz], the space needed is allocated on the heap. Usually you can get the space you want.