Most of the time it's possible to talk your way out of bribes. Sometimes it is necessary though, and that's ok. Here are some tips.
Remember the human behind the bribe
Remember, when dealing with bribes, be as friendly as possible to the officer, and remember that they are only human too. Whilst we don't like to play bribes and associate bribes with corruption, do try to remember that often these officers are very low paid (or in some countries, may frequently have their pays skipped, withheld, or reduced), and in exploiting tourists for bribes, they are supporting their families. I can count on one hand how many times I have actually paid for bribes, and most the time have been able to talk my way out.
Conversation tips to avoid a bribe
To talk yourself out of a bribe, start the conversation very jovially. Express your love and appreciation for their country, and tell the officer how excited you are to finally be visiting their beautiful home country. You can then ask the officer how their shift has been going and when they get off. Or ask them if they're going to relax and have a beer after their shift. These officers are used to tourists arguing, being defensive, or getting aggressive to avoid bribes. If you treat the officer as a friend, engage in friendly conversation, and tell them how much you love their country, they're a lot less likely to ask for a bribe. A friendly smile goes a long way!
Sometimes it's not possible to completely avoid bribes, and in this case the best thing you can do is reduce the bribe. There are a few things that I always do to limit the risk of paying large bribes:
Keep all your cash hidden, and only keep a small day-usage amount in your wallet.
Make sure you have all your cash hidden in your bag where it isn't accessible. In your wallet, only keep what you would be happy to part with to get out of a bribe situation. You don't want this to be such an insignificant amount that the officers will think it worthwhile to detain you, but you don't want it to be so much that this could drastically impact your budget. Usually, I have USD20-30 in my wallet, depending on the country. If the police pull you over and ask you for a fine/bribe, show them that USD20-30 is all you have. They will likely accept that cash you have and let you continue on.
Travel with spare bank cards linked to empty accounts.
The officer requesting a bribe may ask you to follow them to an ATM to take out more cash. You can argue that you don't have access to your account, your card is empty, or that you're meeting a friend in a few days who has the rest of your cash because of your card issues. I have two accounts with cards for my main bank - one card is linked to an empty account, and the other card is my main one. I've only once been taken to an ATM by an officer, but after the card being denied (because the account was intentionally empty), the officer gave up and let me go.
Request they leave you with enough for a taxi / meal.
If the officer is insisting that you need to pay more for a bribe, you can try a different tactic. If they are asking for a USD30 bribe, and a meal in this country costs USD3, you could ask them if they can leave you with just enough for a meal, or for a taxi to your accommodation, so that you're not stranded without food or transport. This will generally take them by surprise, but will also convince them that you don't have any more cash if you're asking them to leave you with a nominal amount. Whether they leave you with the USD3 or not is up to them.
If you feel in any way threatened or unsafe, it is better to just pay the bribe and move along. You cannot put a monetary value on your safety, so if you're even slightly unsure, just pay the bribe and move on.
If you're interested in a story of the only bribe I was ever happy to pay, here's one on how bad decisions leads to bad situations: featuring the Gambian border in the middle of the night!