python fastest way to write to file