I am a forest gnome ranger under the beast master archetype. If I have a flying mount with flyby, like the pteranodon, do I still draw opportunity attacks while riding it?
I would say no. The PHB on page 195 specifically states:
you don't provoke attacks of opportunity when someone or something moves you without using your movement, action, or reaction.
Under the Beast Master archetype on page 93 it says:
You can command the beast where to move on your turn (no action required).
Since the beast counts as something that isn't you, and it doesn't require your action or move, you don't provoke!
From the Monster Manual, page 80:
Flyby. The Pteranadon does not provoke opportunity attacks when flying past an enemy.
The key word there is the Pteranadon. If you are using the Pteranadon as a mount, than you AND the Pteranadon draw opportunity attacks separately. So even if the Pteranadon is free from attacks due to the above ability, the character riding the mount is not.
Pg 198 PHB
While you are mounted you have two options. You can control the mount as your turn...[It's initiative changes to yours]...it only has 3 options: Dash, Disengage and Dodge, or allow it to act independently [if intelligence is high enough]...An independent mount retains it's [own] place in the initiative order and has no restrictions on the actions it can take and moves and acts as it wishes. In either case, if an attack of opportunity is provoked while you are on it, the attacker can target you or the mount.