Accurate alignment of the radio and optical celestial reference frames requires detailed understanding of physical factors that may cause offsets between the positions of the same object measured in different spectral bands. Opacity in compact extragalactic jets (due to synchrotron self-absorption and external free-free absorption) is one of the key physical phenomena producing such an offset, and this effect is well-known in radio astronomy (core shift). We have measured the core shifts in a sample of 29 bright compact extragalactic radio sources observed using very long baseline interferometry (VLBI) at 2.3 and 8.6 GHz. We report the results of these measurements and estimate that the average shift between radio and optical positions of distant quasars would be of the order of 0.1-0.2 mas. This shift exceeds positional accuracy of GAIA and SIM. We suggest two possible approaches to carefully investigate and correct for this effect in order to align accurately the radio and optical positions. Both approaches involve determining a Primary Reference Sample of objects to be used for tying the radio and optical reference frames together.