Method for producing optical waveguides