title: Python Pillow: putpixel() does not record the color correctly
body: <p>I started writing a small library for my game. The essence of the library is to read config from the image. And I ran into such a problem, when recording colors are not recorded correctly! Here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>from PIL import Image
  
  class CustomConfigReader:
      def __init__(self, path):
          self.configPath = path
          self.laters = [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;0&quot;, &quot;Q&quot;, &quot;W&quot;, &quot;E&quot;, &quot;R&quot;, &quot;T&quot;, &quot;Y&quot;, &quot;U&quot;, &quot;I&quot;, &quot;O&quot;, &quot;P&quot;, &quot;A&quot;, &quot;S&quot;, &quot;D&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;J&quot;, &quot;K&quot;, &quot;L&quot;, &quot;Z&quot;, &quot;X&quot;, &quot;C&quot;, &quot;V&quot;, &quot;B&quot;, &quot;N&quot;, &quot;M&quot;, &quot;q&quot;, &quot;w&quot;, &quot;e&quot;, &quot;r&quot;, &quot;t&quot;, &quot;y&quot;, &quot;u&quot;, &quot;i&quot;, &quot;o&quot;, &quot;p&quot;, &quot;a&quot;, &quot;s&quot;, &quot;d&quot;, &quot;f&quot;, &quot;g&quot;, &quot;h&quot;, &quot;j&quot;, &quot;k&quot;, &quot;l&quot;, &quot;z&quot;, &quot;x&quot;, &quot;c&quot;, &quot;v&quot;, &quot;b&quot;, &quot;n&quot;, &quot;m&quot;, &quot; &quot;, &quot;.&quot;, &quot;,&quot;, &quot;!&quot;, &quot;?&quot;]
      def edit(self, y, value):
          l1 = len(value)
          configImage = Image.open(self.configPath).convert(&quot;RGB&quot;)
          for i in range(0, l1):
              l2 = value[i]
              l3 = self.laters.index(l2)
              configImage.putpixel((i, y), (l3, l1, l1))
          configImage.save(self.configPath)
      def read(self, y):
          configImage = Image.open(self.configPath).convert(&quot;RGB&quot;)
          l1 = configImage.getpixel((0, y))[1]
          value = &quot;&quot;
          for i in range(0, l1-1):
              l3 = configImage.getpixel((i, y))[0]
              value += self.laters[l3]
          return value
  
  </code></pre>