def pkcs7_pad(somebytes, blocksize):
  """
  Return a copy of somebytes with PKCS #7 padding added, bringing the length
  up to an even multiple of blocksize.
  """
  somebytes = somebytes.encode('utf-8')
  pad_bytes = blocksize - (len(somebytes) % blocksize)
  temp = [pad_bytes] * pad_bytes
  result = bytes(somebytes) + bytes(temp)
  return result