One of the key elements of terahertz time-domain spectrometers is the optical delay line. Usually it consists of a motorized translation stage and a corner reflector mounted on its top. Errors in the positioning of the translation stage lead to various distortions of the measured waveform of terahertz pulses and, therefore, terahertz spectra. In this paper, the accuracy of position measurements is improved by using an optical encoder. Three types of systematic errors are found: Increasing and periodic offsets of the translation stage position, as well as a drift of its initial position in a series of consecutive measurements. The influence of the detected errors on the measured terahertz spectra is studied and correction methods are proposed.