There's a lot of different solutions and it's mostly going to depend on your personality, your work style and what solution works best for you.
Like others have suggested, charging a consultation fee can be a good solution... the problem with that though is you might wind up turning away potential clients who don't want to pay your consultation fee to get a quote. I freelance at the moment and most of the time my clients are comparing me with one or two other freelancers... if I started charging a consultation fee just to talk to people about a job, I doubt a lot of those companies would have me in the mix in the first place.
I've managed to mostly eliminate this problem from my own work, here's what I found worked for me.
1. Have a fixed hourly rate. Saves a lot of quoting. I charge my time out at $85 an hour, most clients have an idea of how much time they want me to spend on something so they know straight away what I'm going to charge them and they build in a bit of wiggle room in case a job takes longer than expected. Generally, they'll ask me at the start of a job how long I need or they'll say "We've budgeted for 12 hours, is that enough time?"
2. Let your client set the budget. If someone is coming to me and two other people to price a job, I want my cost to be whatever they had in mind in the first place (provided there's enough time to reasonably complete the job of course.) If they aren't just booking me for a set number of hours, then I'll ask "What's your budget". I have a standard quote request form I send people and it's one of the first questions on that form. If their budget is unreasonable, then I can politely decline the work without wasting any more time. If the budget is reasonable then I can cost in some time, allowing for initial work and revisions, that comes in roughly around what they had budgeted. Oftentimes I actually beat out competitors who cost a job for less than me because my cost is roughly what they budgeted for, not way under or way over. They know they can't afford the guy who is way over, they assume the guy who's way under isn't going to do very good work, and they go with me.
I know these ideas seem (extremely) simple... but surprising how many freelancers aren't pricing jobs this way.