Implement snprintf