For Pokemon Red and Blue there is a glitch that actually allows you to get Mew before even taking on the second gym. Before you start, make sure you have plenty of Pokeballs, as youll need them to get Mew. Follow these steps to give it a shot.
Get to Cerulean City, where the second gym is located, clear the Nugget Bridge that takes you to Route 24, battling your rival on the way. Stop fighting at this point, this is very important to the rest of the steps for how to get Mew in Pokemon Yellow, Red, and Blue.
At the top of the bridge, on the left side past some water and standing two rows of grass down in a field youll see a single trainer. Dont fight him, you need him for other purposes. Walk around him, keeping out of his sightline, and keep doing this until you catch an Abra (this is probably the hardest part and will take a while.
Once youve got him, head left to Route 25. Finish off every single trainer here except for a single, specific one. Youll see him standing north of two rocks with a female trainer two spaces to the south, with a pillar of five rocks standing to his left (as he is facing north). If you have trouble spotting him, just save your game and battle everyone. Once you find the trainer with a level 17 Slowpoke you have found your guy. Load the game up from the previous save and fight everyone but him. Save your game at this point to prevent any issues.
Use Abras teleport ability to head to the Pokecenter to heal up. Now go back to where you caught Abra and stand at the top left corner of the water, next to the bridge.Save your game again. Once youre ready to try the glitch, press down and start at the same time. The key is to get the trainers attention, while pausing the game at the same time.
If this seemed to work, use Abras teleport ability once again, then head back to Route 25 and fight the Youngster that you left there. You need to make sure he walks into you and not the other way around or Pokemon Red and Pokemon Blue might crash. Once hes defeated you need to teleport away again.
Once you make it back to Cerulean City head back to the bridge. If all was done correctly, once you walk across the border from the city to Route 24 your menu will open on its own. Press B or Start to close and BAM! Mew will be fighting you. Hes only a level 7, so pretty easy to catch. Just be careful not to knock him out.
Once you have him you are good to go. You can just wait for Pokemon Sun and Moon to hit and then transfer him to the new games via Pokemon Bank.