Study of the B -> J/psi K- pi+ pi- decay and measurement of the B -> X(3872) K- branching fraction