To keep a long-term copy of IM messages:
  1. go to https://www.facebook.com/messages/
  2. scroll back as far as you need to (you can go back quite a ways, though it may take a little time to wait on the browser
  3. select with your mouse, or with Ctrl-A, and copy-n-paste into a plain-text editor
  4. use this script to fix some of the formatting problems