Generally, visualisation helps reduce the stress response within the body, which can contribute to increased pain. This stress response increases cortisol and other hormones which may cause more inflammation throughout the body. The more inflamed your joints are, the more pain you will likely experience.
Thus, by calming this response in the body, you can not only reduce pain but also decrease anxiety and stress as well.
For example, you may imagine a peaceful and stress-free scenery. Perhaps this takes on the form of a beautiful green field with the sun beaming down. You can feel the wind in your hair.