The Evolution of Dust Opacity in Galaxies