diff --git a/textimage.module b/textimage.module
index dd64a64..c6b5a10 100644
--- a/textimage.module
+++ b/textimage.module
@@ -36,6 +36,11 @@ define('ALIGN_LEFT', 1);
 define('ALIGN_CENTER', 2);
 define('ALIGN_RIGHT', 3);
 
+define('FORMAT_JPG', 1);
+define('FORMAT_PNG', 2);
+define('FORMAT_GIF', 3);
+define('FORMAT_BMP', 4);
+
 /**
  * Implementation of hook_help().
  */
@@ -115,7 +120,6 @@ function textimage_theme() {
         'preset',
         'text',
         'additional_text' => array(),
-        'format' => 'png',
         'alt' => '',
         'title' => '',
         'attributes' => array(),
@@ -141,8 +145,9 @@ function textimage_theme() {
 function textimage_menu() {
   $items = array();
 
-  $items[file_directory_path() .'/textimage'] = array(
+  $items['textimage/%'] = array(
     'page callback' => 'textimage_image',
+    'page arguments' => array(1),
     'access arguments' => array('access textimages'),
     'type' => MENU_CALLBACK,
   );
@@ -247,46 +252,45 @@ function textimage_perm() {
  *
  */
 function textimage_image() {
-  $args = explode('/', str_replace(base_path() . file_directory_path() .'/textimage/', '', $_SERVER[REQUEST_URI]));
+  $args = func_get_args();
 
   $preset = array_shift($args);
   if (is_numeric($preset)) {
     drupal_not_found();
   }
 
-  $filename = urldecode(array_pop($args));
+  $text = urldecode(array_pop($args));
   $additional_text = $args;
 
-  // Determine our output format
-  preg_match('/\.([a-z]+)$/i', $filename, $matches);
-  $format = $matches[1];
-  if ($format == 'jpg') {
-    $format = 'jpeg';
-  }
-
-  // Determine the text to display
-  $text = preg_replace('/\.([a-z]+)$/i', '', $filename);
-
-  if (!$img = textimage_build_image($preset, $text, $additional_text, $format)) {
+  if (!$img = textimage_build_image($preset, $text, $additional_text)) {
     return FALSE;
   }
 
   drupal_goto($img);
 }
 
-function textimage_build_image($preset, $text, $additional_text = array(), $format) {
-  // Integrety check
-  $output_function = 'image'. $format;
-  if (!function_exists($output_function)) {
-    $message = t('Unable to generate Textimage as the file extension is unsupported on this system. Files must have a .png, .jpg, or .gif extension.');
+function textimage_build_image($preset, $text, $additional_text = array()) {
+
+  $formats = array(
+	    FORMAT_JPG => array('func' => 'jpeg', 'ext' => 'jpeg'),
+	    FORMAT_PNG => array('func' => 'png', 'ext' => 'png'),
+	    FORMAT_GIF => array('func' => 'gif', 'ext' => 'gif'),
+	    FORMAT_BMP => array('func' => 'wbmp', 'ext' => 'bmp'),
+	  );
+
+  // Load preset
+  if (!$preset = _textimage_preset_load($preset)) {
+    $message = t('Unable to generate Textimage as the preset %preset is not defined.', array('%preset' => $preset));
     watchdog('textimage', $message, WATCHDOG_ERROR);
     drupal_set_message($message, 'error');
     return FALSE;
   }
 
-  // Load preset
-  if (!$preset = _textimage_preset_load($preset)) {
-    $message = t('Unable to generate Textimage as the preset %preset is not defined.', array('%preset' => $preset));
+  $format = $formats[$preset['settings']['image']['format']];
+
+  $output_function = 'image'. $format['func'];
+  if (!function_exists($output_function)) {
+    $message = t('Unable to generate Textimage as the file extension is unsupported on this system. Files must have a .png, .jpg, or .gif extension.');
     watchdog('textimage', $message, WATCHDOG_ERROR);
     drupal_set_message($message, 'error');
     return FALSE;
@@ -294,14 +298,14 @@ function textimage_build_image($preset, $text, $additional_text = array(), $form
 
   $result = db_query(
     "SELECT file FROM {textimage_image} WHERE pid = %d AND data = '%s'",
-    $preset['pid'], serialize(array('format' => $format, 'text' => $text, 'additional_text' => $additional_text))
+    $preset['pid'], serialize(array('format' => $format['ext'], 'text' => $text, 'additional_text' => $additional_text))
   );
 
   if (!$result = db_fetch_object($result)) {
     // Generate the image resource
     $img = textimage_image_from_preset($preset['pid'], $text, $additional_text);
 
-    $filename = time() .'.'. $format;
+    $filename = time() .'.'. $format['ext'];
     $directory = file_directory_path() .'/textimage/'. $preset['pid'];
 
     // Save the result so we don't have to recreate
@@ -312,7 +316,7 @@ function textimage_build_image($preset, $text, $additional_text = array(), $form
     db_query(
       "INSERT {textimage_image} (pid, file, data) VALUES ('%s', '%s', '%s')",
       $preset['pid'], $directory .'/'. $filename,
-      serialize(array('format' => $format, 'text' => $text, 'additional_text' => $additional_text))
+      serialize(array('format' => $format['ext'], 'text' => $text, 'additional_text' => $additional_text))
     );
 
     return $directory .'/'. $filename;
@@ -848,14 +852,14 @@ function textimage_field_formatter_info() {
 }
 
 function theme_textimage_formatter($element) {
-  return theme('textimage_image', $element['#formatter'], $element['#item']['safe'], array(), 'png', $element['#item']['safe'], $element['#item']['safe']);
+  return theme('textimage_image', $element['#formatter'], $element['#item']['safe'], array(), $element['#item']['safe'], $element['#item']['safe']);
 }
 
 /**
  * Theme function for displaying textimages
  */
-function theme_textimage_image($preset, $text, $additional_text = array(), $format = 'png', $alt = '', $title = '', $attributes = array(), $getsize = TRUE) {
-  if (!$path = textimage_build_image($preset, $text, $additional_text, $format)) {
+function theme_textimage_image($preset, $text, $additional_text = array(), $alt = '', $title = '', $attributes = array(), $getsize = TRUE) {
+  if (!$path = textimage_build_image($preset, $text, $additional_text)) {
     return FALSE;
   }
   return theme('image', $path, $alt, $title, $attributes, $getsize);
diff --git a/textimage_admin.inc b/textimage_admin.inc
index 2ffdebc..4a67d67 100644
--- a/textimage_admin.inc
+++ b/textimage_admin.inc
@@ -159,6 +159,26 @@ function textimage_preset_edit(&$form_state, $op, $pid = NULL) {
     '#rows' => 1,
   );
 
+  $form['settings']['image'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Image settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  $form['settings']['image']['format'] = array(
+    '#type' => 'select',
+    '#title' => t('Image format'),
+    '#description' => t('Format for saving images.'),
+    '#options' => array(
+	    FORMAT_JPG => 'JPEG', 
+	    FORMAT_PNG => 'PNG',
+	    FORMAT_GIF => 'GIF',
+	    FORMAT_BMP => 'BMP',
+    ),
+    '#default_value' => $preset['settings']['image']['format'],
+  );
+
   $form['settings']['text'] = array(
     '#type' => 'fieldset',
     '#title' => t('Text Settings'),
