Church group agrees to buy old St. William's