You must have every other mask in the game - this is crucial. Then once you enter the moon to fight Majora, you can see four kids running around a tree with the bosses masks on their faces. If you give them masks, you can play their games. You have to win ALL FOUR GAMES. Then you will be given the fierce deity mask. (once you save, you get all your masks back, and you get to keep the fierce deity mask).