My ex was studying psychology and working with patients at the time we were together. His method to deal with pessimism was to "ignore inappropriate behavior." So when the person keeps talking about how bad things are, you continually ask them things like, "What can you do to improve this?" Or "How can you avoid this in the future?" Any question related to personal responsibility and action will help.
So that was many years ago, and I have used this trick a lot. I am never depressed and always see the bright side and better days coming. But I agree with you that being around naysayers is hard. When I start asking them these questions, they either improve or won't come near me at all :)