Form factors, deformed Knizhnik-Zamolodchikov equations and finite-gap integration