Measurement of the X(3872) production cross section via decays to J/ψπ+π−