improve mat file output