Write custom Lua writer to input directory if writeable; output directory if not