Learning to Reason and Memorize with Self-Notes