Compensation of drifts in the characteristics of light emitting or modulating elements