Fix sparse matrix binary file writing