Linear series of low degree on plane curves and the Castelnuovo function