Conditions for factorizable output from a beam splitter