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).
Are the values in `self._synapsesForSourceCell` sets of (synapse, someData) tuples? Seems a little janky to add and remove from a set like this. Could you change from a set to a dict mapping synapse to data? That would make removing or replacing the data for a synapse much easier and you can still iterate over the synapse/data pairs with `dict.iteritems()`.