How to turn stock losses into tax savings, and other ways to trim your tax bill