I have some transactions pending in the memory pool, how do I empty the memory pool without restarting bitcoind ? I would like the transactions to be cancelled also.
Has the transaction already been mined into a block? I'm assuming not since it's in your raw mem pool. Why wasn't it mind in that case? Did it not have any fee?
I would try sending the coins to yourself with a much larger fee than the original transaction. Like Steven Roose said above, once transactions have been sent out to the network, they can't really be undone. Even if you delete it from your raw mem pool, it's still in everyone elses raw mem pool just waiting to be confirmed.
To make your own custom transaction that spends the UTXOs you want to spend, use the rpc calls:
listtransactions listunspent createrawtransaction signrawtransaction
The default behaviour is for clients to accept whatever transactions spend an UTXO first. So most standard clients will not accept secondary spends of specific UTXOs. Mining pools may be a little bit more persuadable.
Not sure how viable this is, but I just found this: http://www.bitundo.com/. Read up on it before giving any money to a service like this. It also only works for transactions that haven't been confirmed into blocks at all yet.
I would also read this article http://bitcoinmagazine.com/2960/instant-transaction-fraud-an-explanation/. It has some very interesting stuff relevant to this question.