Inplace transpose of 2d array