serialize data using pickle