Added transpose method

Added a specialsed transpose method which checks if the output array has enough memory. If it does not it allocates memory