title: base64 error when decoding a string in python
body: <p>I am working on a chat room that can send images. But the images are large so I send them in part and add each part to a string. And when i try to decode the string that has the information in it I get this error:</p>
  
  <pre><code>return binascii.a2b_base64(s)
  Error: Incorrect padding
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>def getData(self):
      chatArea = self.chatArea
  
      imageBytes = ""
      imageMode = False
  
      while 1:
          data = self.s.recv(8000)
          if not data:
              break
  
          if imageMode == True:
              imageBytes = imageBytes + data
  
              if data[-1] == ")":
                  newImage = open("Untitled.png", "wb")
                  newImage.write(imageBytes.decode("base64"))
                  newImage.close()
                  imageMode = False
                  print("Done")
          else:
              if re.findall(r'\[(.*?)\]', data) == ["Image"]:
                  print("Got the data")
                  imageMode = True
              else:
                  string = data + "\n\n"
                  chatArea.configure(state=NORMAL)
                  chatArea.insert(END, string)
                  chatArea.configure(state=DISABLED)
  
                  newString = string.split(":")[0]
  
                  self.chatArea.see(END)
  
          if newString == self.myName or newString == "Server":
              pass
          else:
              winsound.PlaySound("Notify.wav", winsound.SND_FILENAME)
  </code></pre>
  
  <p>Why am i getting this error when i try to create the image?
  How can I fix it?</p>