switched options to a hash, added encoding option.