Transfer matrix method to compute energy levels of superlattices