Contour integral solutions of Sylvester-type matrix equations