Turn portfolio losses into a win. Here are three ways to cut your taxes