I don't see any prob with your calc. The entropy will depend on both the distribution and the number of bins used - the quantization of the input array Z. As an experiment, I replaced the array Z with an array of uniformly distributed random numbers. With the # bins=256, your entropy calc=8bits(as expected); with #bins=64, the mcd calc gives entropy=6bits. (Careful with units also). #bins=200 gives entropy=7.64bits with uniformly distributed Z and the 6.6 with original Z. This all makes sense.
The quantization (#bins) is the key. If you make the #bins=2 in your calc (asymmetric binary distribution), the resulting entropy=0.476bits. I suspect the matlab calc is making some assumptions in its calc that are different from those in your mcd calc.
One other comment. The calc results will be an upper bound, since they (mcd and matlab) include an assumption that all elements of Z are independent. If true, thiswould make it appear as a uniformly noisy field(which it is not) with a white spectrum. While this may be approximately true here, it may not hold in general for the images of interest. The correlations are exploited by all compression algorithms.
Lou