Calculation of master integrals by difference equations