Dunottar school saved from closure