US President Barack Obama has said he will ban solitary confinement as a form of punishment for juvenile and low-level offenders in federal prisons.