Basically you can get a masterball in two places. One, like J98 said, you get right in front of the gate to route 10. You must beat the 8th gym first. Second, like james said, you can get in the Castelia City pokemon center when you have traded 50 times. Good luck getting them!
Hope this helps =)