Optimize temporal memory

Fixes https://github.com/numenta/nupic/issues/1410.
Fixes #1405.

Main optimization: Instead of storing the full set of active synapses for each segment, only store the number of active synapses for each segment, and separately store the indices of the active synapses for only the active segments (ones that caused a prediction).
Good idea, will do!