Added write method. Pickling works on Mac but not linux. Need to investigate