Python Write Matrix To File