fix encoding when output rtmatrix