title: Using IMAP to extract headers error TypeError: initial_value must be str or None, not bytes
body: <p>Here is my code that connects to gmail and parses the emails:</p>
  
  <pre><code>import imaplib
  from email.parser import HeaderParser
  
  conn = imaplib.IMAP4_SSL('imap.gmail.com')
  conn.login('example@gmail.com', 'password')
  conn.select()
  conn.search(None, 'ALL')
  data = conn.fetch('1', '(BODY[HEADER])')
  header_data = data[1][0][1]
  parser = HeaderParser()
  msg = parser.parsestr(header_data)
  </code></pre>
  
  <p>At this stage i get the error message "TypeError: initial_value must be str or None, not bytes"</p>
  
  <p>Im using python 3. How do i convert the result to a string so ican parse the headers using parser.parsestr?</p>