Matrix Riemann-Hilbert problems and factorization on Riemann surfaces