Formation energy of point defects in free surfaces and grain boundaries in MgO