A general algorithm for computing bound states in infinite tight-binding systems