API for fast construction of packed arrays
fix NULL deref when the script encoding wasn't previously set