First principles determination of magnetostriction in bulk transition metals and thin films