You're quite mistaken that the Black Codes only lasted until 1867. The were imposed by states and municipalities over a period of time and were all encompassing. No federal law or passage of the 14th and 15th Amendments instantly wiped those laws off the books or kept them from being enforced. There was great improvement during Reconstruction but only because of the federal troops remaining throughout the South to protect those gains (somewhat). Violation of those codes could still get one lynched or jailed. Convict labor never went away as the loophole in the 13th Amendment still existed.