Defenders of torture inevitably raise the dreaded "ticking time bomb" scenario. Leaving aside questions about the plausibility of such a scenario (I have my doubts, but I'm not privy to classified intelligence), there is an obvious solution that doesn't involve legalizing torture.
At common law, courts have long recognized the defense of necessity (sometimes called "choice of evils".) For example, a jury may refuse to convict a criminal defendant if: 1) he was faced with a clear and imminent danger; 2) he reasonably thought his action would abate the danger; and 3) there was no legal alternative. See Commonwealth v. Pike, for example. In the context of torture, see the opinion of the Supreme Court of Israel in Judgement on the Interrogation Methods Applied by the GSS.
If instructions on the necessity defense were allowed in prosecutions for torture, no jury would convict a defendant who could show he was faced with a true "ticking time bomb" scenario. Yet this is very different from prospectively legalizing torture, since the putative torturer, faced with the prospect of a criminal prosecution, would be less likely to proceed without a genuine justification.
Unfortunately, the Supreme Court effectively ruled out a general necessity defense to federal criminal law in United States v. Oakland Cannabis Buyers' Cooperative. But there is nothing to stop Congress from enacting a necessity exception to the federal torture statute. Provided the government aggressively prosecutes torture cases (including those involving the CIA), I would support such an exception. I'm guessing it would get used quite infrequently, if ever.
UPDATE: Just to be clear: When I suggest that Congress enact a necessity exception to the torture statute, I mean an exception that allows for a necessity defense to be raised by a criminal defendant, not an exception that prospectively precludes prosecution.