Fix segfault that occurs when emitting factors with NAs

- Closes #12.