Fixed mGradMag and convertMex, found segFault in gradQuantize