diff --git a/base58.py b/base58.py
index 734e5d1..f03e3a4 100644
--- a/base58.py
+++ b/base58.py
@@ -14,7 +14,7 @@ from hashlib import sha256
 __version__ = '0.2.5'
 
 # 58 character alphabet used
-alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
+alphabet = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
 
 
 if bytes == str:  # python2
@@ -31,22 +31,33 @@ else:  # python3
     )
 
 
+def scrub_input(v):
+    if isinstance(v, str) and not isinstance(v, bytes):
+        v = v.encode('ascii')
+
+    if not isinstance(v, bytes):
+        raise TypeError(
+            "a bytes-like object is required (also str), not '%s'" %
+            type(v).__name__)
+
+    return v
+
+
 def b58encode_int(i, default_one=True):
     '''Encode an integer using Base58'''
     if not i and default_one:
-        return alphabet[0]
-    string = ""
+        return alphabet[0:1]
+    string = b""
     while i:
         i, idx = divmod(i, 58)
-        string = alphabet[idx] + string
+        string = alphabet[idx:idx+1] + string
     return string
 
 
 def b58encode(v):
     '''Encode a string using Base58'''
-    if not isinstance(v, bytes):
-        raise TypeError("a bytes-like object is required, not '%s'" %
-                        type(v).__name__)
+
+    v = scrub_input(v)
 
     nPad = len(v)
     v = v.lstrip(b'\0')
@@ -59,14 +70,13 @@ def b58encode(v):
 
     result = b58encode_int(acc, default_one=False)
 
-    return (alphabet[0] * nPad + result)
+    return (alphabet[0:1] * nPad + result)
 
 
 def b58decode_int(v):
     '''Decode a Base58 encoded string as an integer'''
 
-    if not isinstance(v, str):
-        v = v.decode('ascii')
+    v = scrub_input(v)
 
     decimal = 0
     for char in v:
@@ -77,16 +87,10 @@ def b58decode_int(v):
 def b58decode(v):
     '''Decode a Base58 encoded string'''
 
-    if not isinstance(v, str):
-        v = v.decode('ascii')
-
-    if not isinstance(v, str):
-        raise TypeError(
-            "a string-like object is required (also bytes), not '%s'" %
-            type(v).__name__)
+    v = scrub_input(v)
 
     origlen = len(v)
-    v = v.lstrip(alphabet[0])
+    v = v.lstrip(alphabet[0:1])
     newlen = len(v)
 
     acc = b58decode_int(v)
diff --git a/tox.ini b/tox.ini
index 33e915e..45d5087 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,4 +3,4 @@ envlist = py27,py35
 
 [testenv]
 deps = -rtest-requirements.txt
-commands = pytest --pep8 --flakes --cov=base58 .
+commands = pytest --pep8 --flakes --cov=base58 . []

output as a byte array
currently your encode function spits out a string, which is annoying because I have to wrap the output in the str.encode() method. 

diff --git a/test_base58.py b/test_base58.py
index d76c2c1..feb020a 100644
--- a/test_base58.py
+++ b/test_base58.py
@@ -6,6 +6,16 @@ from base58 import (
     b58decode_int, alphabet)
 
 
+if bytes == str:
+    bytes_from_char = (
+        lambda c: c
+    )
+else:
+    bytes_from_char = (
+        lambda c: bytes([c])
+    )
+
+
 class RaisesContext(object):
     pass
 
@@ -27,17 +37,17 @@ def assert_raises(matcher=None, message=''):
 
 def test_simple_encode():
     data = b58encode(b'hello world')
-    assert_that(data, equal_to('StV1DL6CwTryKyV'))
+    assert_that(data, equal_to(b'StV1DL6CwTryKyV'))
 
 
 def test_leadingz_encode():
     data = b58encode(b'\0\0hello world')
-    assert_that(data, equal_to('11StV1DL6CwTryKyV'))
+    assert_that(data, equal_to(b'11StV1DL6CwTryKyV'))
 
 
 def test_encode_empty():
     data = b58encode(b'')
-    assert_that(data, equal_to(''))
+    assert_that(data, equal_to(b''))
 
 
 def test_simple_decode():
@@ -91,14 +101,9 @@ def test_round_trips():
             assert_that(bytes_in, equal_to(bytes_out))
 
 
-def test_input_should_be_bytes():
-    data = u'3vQB7B6MrGQZaxCuFg4oH'
-    with assert_raises(TypeError):
-        b58encode(data)
-
-
 def test_simple_integers():
     for idx, char in enumerate(alphabet):
+        char = bytes_from_char(char)
         assert_that(b58decode_int(char), equal_to(idx))
         assert_that(b58encode_int(idx), equal_to(char))
 

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-pep8 pytest-flakes pytest-cov PyHamcrest mock matchmock coveralls
3.6
test-requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
-e git+https://github.com/keis/base58.git@5444801b217436757d3f9fbab129652017fca3d9#egg=base58
certifi==2021.5.30
charset-normalizer==2.0.12
coverage==6.2
coveralls==3.3.1
docopt==0.6.2
execnet==1.9.0
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
matchmock==2.1.1
mock==5.2.0
packaging==21.3
pep8==1.7.1
pluggy==1.0.0
py==1.11.0
pyflakes==3.0.1
PyHamcrest==2.1.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cache==1.0
pytest-cov==4.0.0
pytest-flakes==4.0.5
pytest-pep8==1.0.6
requests==2.27.1
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: base58
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - charset-normalizer==2.0.12
      - coverage==6.2
      - coveralls==3.3.1
      - docopt==0.6.2
      - execnet==1.9.0
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - matchmock==2.1.1
      - mock==5.2.0
      - packaging==21.3
      - pep8==1.7.1
      - pluggy==1.0.0
      - py==1.11.0
      - pyflakes==3.0.1
      - pyhamcrest==2.1.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cache==1.0
      - pytest-cov==4.0.0
      - pytest-flakes==4.0.5
      - pytest-pep8==1.0.6
      - requests==2.27.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/base58

test_base58.py::test_simple_encode test_base58.py::test_leadingz_encode test_base58.py::test_encode_empty test_base58.py::test_simple_integers
test_base58.py::test_simple_decode test_base58.py::test_simple_decode_bytes test_base58.py::test_leadingz_decode test_base58.py::test_leadingz_decode_bytes test_base58.py::test_empty_decode test_base58.py::test_empty_decode_bytes test_base58.py::test_check_identity test_base58.py::test_check_failure test_base58.py::test_round_trips test_base58.py::test_large_integer
base58.py tox.ini
base58.py tox.ini