Latrobe's advice is good. Bear in mind, there are many ways to go about BnZ defense. I don't use Titanic's approach because it loses alt aggressively. If you've got alt to play with, and you're against a higher 109, it has its advantages because it keeps the fight fast, where a P47 is better off against a 109. It does work and is a very effective way of definitely avoiding the shot, I just personally don't like the alt loss.
To add to what's been said, based on the scenario you described the first thing you should do when you see a bandit is go level. If you're really slow, like on autoclimb, maybe even go into a shallow dive to get some speed up. Getting up to decent speed (around 300) initially is more important than alt.
When defending against a guy with alt, I feel it's important to avoid the natural tendency to want to climb hard. If you do that, you're making yourself an easier target. My normal schtick is to turn toward the guy nose slightly low to ruin his shot. I'm typically wanting him coming in from about 2 o'clock high or so when he's in range for the shot. As he gets to around 800 yards, I also either pull up, or push down. You never want to be moving in a straight line when he takes his shot.
Another thing you want to do, is if he is in gunnery range you want to roll your plane so it's skinny to him. Roll so your wings are in line with him or close to in line so he has a smaller target to shoot at. This is easiest to illustrate in the P38. From the top, it's a freaking HUGE target. Roll so you're sideways to him, it's much much smaller. Jugs make a pretty big target from the top too.
Your goal when someone's BnZing you is to equalize your E with his. You have to balance that with moving enough for him to miss you. That's the tricky part. The attacker is trying to anticipate where you will be to put his bullets in front of you. Your job is to move in such a way that he guesses wrong.
To be safest, you can haul hard on the stick, so your plane is turning hard when he gets within gunnery range. The downside with that is you bleed a lot of E doing it. I recommend in the beginning, turn more aggressively to be sure to get out of his way. It costs you more E, but you'll survive.
As you become better at reading planes on the way in, you will get a feel for the timing you need to have to move in such a way he can't get guns on. I actually start my setup for him to miss me when he's about 2000 yards out. I rarely pull more than 2 g's to slip a BnZer. If I'm otherwise occupied and he surprises me, then I have to pull harder.
That comes with practice though. I spent about 6-8 months when I started this game almost constantly intentionally looking for high bandits to practice my defense. I consider mine passable, but I still get tagged every once in a while by guys with good gunnery.
The reason I try for the smoother, E retaining turns is because my goal is to get him to miss, and while he's resetting, shallow climb away from him. I shallow climb at about 1-1.5k/minute, and only if I'm above 250mph. Once my indicated hits 250 I reduce my climb rate to maintain it if he's not pressing, or start turning back into him if he's coming back.
The shallower of an angle he has to get to you, the easier of a time you have avoiding his attack. I just want to reiterate one point Latrobe mentioned, the absolute WORST place to be is directly down from a higher bandit. From directly above you, it is the easiest possible position for him to get guns on you.
tl;dr: Make smooth, E retaining turns to avoid his gunnery, and shallow climb away from him when you're able. Keep your speed up when you're able.
Wiley.