If your main head shows signs of beginning to flower, harvest it immediately, taking at least 6 inches from the stem; cut at a slant. Ideally, you should harvest the head before those buds open, because it will be a little tougher and may not be as tasty, but they are still edible, especially if just a few of the flower buds have started to open.
The plant may also, as you have found, produce side shoots that will continue to develop after the main head is harvested. These will not develop into large heads, but are useful to harvest as florets. When they are of a decent size, harvest them to encourage more to develop. Eventually, after several weeks, the plant will stop producing. For more tips on harvesting, check the “Harvest/Storage” section in the above article. Hope this helps!