\[3x + xy^{2} - x^{2}y - 3y =\]
\[= (3x - 3y) - \left( x^{2}y - xy^{2} \right) =\]
\[= 3(x - y) - xy(x - y) =\]
\[= (x - y)(3 - xy).\]