After defeating Valerie in Laverre City, your friends will tell you to meet up near the Poké Ball Factory, at the northern part of the city. After beating Team Flare in the factory, the president of the factory will give you a Master Ball. The Master Ball is obtained in the storyline.
Another way to get a Master Ball is the Lottery Corner found in Lumiose City on Estival Avenue. If you can't find it, just take a cab there. Enter a cab, and pick services, one of the options is the Loto-ID Center, which is the lottery. Matching all five numbers, is a Master Ball, according to Serebii.net.