Finite-size effects in theories with factorizable S-matrices