Fix CSV output of matrices to be in column-major order

Resolves #181