First, How Much Is Your Real Gain...
Many people mistakenly believe that their gain is simply the profit on the sale ("We bought it for $100,000 and sold it for $650,000, so that's a $550,000 gain, and we're $50,000 over the exclusion, right?"). It's not so simple -- a good thing, since the fine print can work to your benefit in such instances.
Your gain is actually your home's selling price, minus deductible closing costs, selling costs, and your tax basis in the property. (Your basis is the original purchase price, plus purchase expenses, plus the cost of capital improvements, minus any depreciation and minus any casualty losses or insurance payments.)
Deductible closing costs include points or prepaid interest on your mortgage and your share of the prorated property taxes.
Examples of selling costs include real estate broker's commissions, title insurance, legal fees, advertising costs, administrative costs, escrow fees, and inspection fees.
So, for example, if you and your spouse bought a house for $100,000 and sold for $650,000, but you'd added $20,000 in home improvements, spent $5,000 fixing the place up for the sale, and paid the real estate brokers at least $25,000, the exclusion plus those costs would mean you'd owe no capital gains tax at all.
For more information, see IRS Publication 551, Basis of Assets, and look for the section on real property.