We evaluate analytically higher terms of the epsilon-expansion of the three-loop master integrals corresponding to three-loop quark and gluon form factors and to the three-loop master integrals contributing to the electron g-2 in QED up to the transcendentality weight typical to four-loop calculations, i.e. eight and seven, respectively. The calculation is based on a combination of a method recently suggested by one of the authors (R.L.) with other techniques: sector decomposition implemented in FIESTA, the method of Mellin--Barnes representation, and the PSLQ algorithm.