'Returns a base64 encoded bitmask of the pieces that we have.'

@checkHandleAndSynchronize('')
def get_pieces_base64(self):

    bitstr = ''
    for bit in self.handle.status().pieces:
        bitstr += ('1' if bit else '0')
    encoded_str = ''
    for i in range(0, len(bitstr), 8):
        encoded_str += chr(int(bitstr[i:(i + 8)].ljust(8, '0'), 2))
    return base64.b64encode(encoded_str)
