added writing to pickle and MongoDB to lattice