code: def get_buffer(self, data_np, header, format, output=None):
          
          if not have_pil:
              raise Exception("Install PIL to use this method")
          image = PILimage.fromarray(data_np)
          buf = output
          if buf is None:
              buf = BytesIO()
          image.save(buf, format)
          return buf
docs: Get image as a buffer in (format).
          Format should be 'jpeg', 'png', etc.