Maintaining a memory by transcriptional autoregulation