If you're doing heroic (meaning 7/7, not just Kargath) or mythic, it's intellect > spirit > mastery > the rest. Depending on the fight, spirit may be less considerably less valuable, sometimes to the point of being almost useless. With the current tier being the way it is, I'd say mastery is better than spirit on everything except imperator, but mana regeneration tends to be rather subjective and depends a lot on your raid group. Either way, mastery really shines when you're doing difficult content with relatively few healers (to get more DPS) and when you're good at timing your cooldowns to make the most of it. The better your timing is, the better mastery gets.
If you're only doing normal or casual heroic, it might be theoretically better to stack something other than mastery, but it doesn't really matter anyway. At that point you've most likely got more healers than are actually necessary, and if you wipe it's because of not handling mechanics, insufficient DPS, or healers who aren't skilled enough, not because your raw HPS over the course of the fight is lacking.