Origin and roles of oxygen impurities in hexagonal boron nitride epilayers