First-principles study of the optical properties of BeO in its ambient and high-pressure phases