support allow_none and encoding options